﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace TB_WS.Class
{
    public class WX_Reply
    {
        public static int Insert_WX_Reply(int Seller_ID,
            string WXR_Type,string WXR_Str)
        {
            if (get_WXR_INFO_count(Seller_ID, WXR_Type) == 0)
            {
                string sql = "insert into WX_Reply values(" + Seller_ID + ",'" +
                    WXR_Type + "','" + WXR_Str + "')";
                return Class.Unit.db_Conn.Nonquery(sql);
            }
            else
            {
                return -1;
            }
        }

        public static int get_WXR_INFO_count(int Seller_ID,
            string WXR_Type)
        {
            string sql = "select count(*) from WX_Reply where Seller_ID=" + Seller_ID + " and WXR_Type='" + WXR_Type + "'";
            return Convert.ToInt32(Class.Unit.db_Conn.scalar(sql));
        }

        public static DataSet get_WXR_Info(int Seller_ID,
            string WXR_Type)
        {
            string sql = "select * from WX_Reply where WXR_Type='" +
                WXR_Type + "' and Seller_ID=" + Seller_ID;
            return Class.Unit.db_Conn.select(sql);
        }

        public static int Update_WXR_Str(int Seller_ID,
            string WXR_Type, string WXR_Str)
        {
            string sql = "update WX_Reply set WXR_Str='" +
                WXR_Str + "' where WXR_Type='" +
                WXR_Type + "' and Seller_ID=" + Seller_ID;
            return Class.Unit.db_Conn.Nonquery(sql);
        }
    }
}